import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.GlobalHeaders;
import cn.hutool.http.HttpUtil;
import com.sl.core.engine.utils.BeanUtil;
import com.sl.core.utils.JsonUtil;

import java.util.List;
import java.util.Map;

public class MatrixTopicSearch {
    public static void main(String[] args) {
        String url = "http://matrix-gyfy.seenew.info:10040/v1/middlewareManage/mq/message/list";
        String cookie = "_ga=GA1.1.1119290165.1734960105; _ga_0C4M1PWYZ7=GS1.1.1734960104.1.1.1734961045.0.0.0; _ga_T11SF3WXX2=GS1.1.1734962195.2.0.1734962195.60.0.0; _ga_K2SPJK2C73=GS1.1.1734962195.2.0.1734962195.60.0.0; prod_c2f_token=YzJmOjhhMjczMWRjYWRhYTRkOWFhOWUxYmE3OTY3Zjk1NGY0.a2VsZRGzIA7SSXyt9nUkukg4P+8LEv6hX7ScvM8xICQ8GvPjDWfZDxpc5BE/zx59kizFWxwZLBsZ2fL482D77YTC93LzNNViccNxpfmBUvJTavhXHAbFsxbpgNVXB1VEo6udzXtz0uVEaRCI; prod_hbos_token=YzJmOjhhMjczMWRjYWRhYTRkOWFhOWUxYmE3OTY3Zjk1NGY0";

        String param = "{\n" +
                "  \"instanceId\": 24,\n" +
                "  \"topicName\": \"TOPIC_HBOS_EMR\",\n" +
                "  \"startTime\": \"2025-06-03 13:49:00\",\n" +
                "  \"endTime\": \"2025-06-03 13:49:59\",\n" +
                "  \"pageIndex\": 1,\n" +
                "  \"pageSize\": 20000\n" +
                "}";

        GlobalHeaders.INSTANCE.header("cookie",cookie);
        String result = HttpUtil.post(url, param);
        Map<String, Object> map = JsonUtil.toMap(result);
        Object property = BeanUtil.getProperty(map, "$.data.dataSource");
        if(property instanceof List pl){
            pl.forEach(v->{
                if(v instanceof Map m){

                    String turl = "http://matrix-gyfy.seenew.info:10040/v1/middlewareManage/mq/message";
                    String pa = "{\n" +
                            "  \"instanceId\": 24,\n" +
                            "  \"topicName\": \""+MapUtil.getStr(m,"topic")+"\",\n" +
                            "  \"msgId\": \""+ MapUtil.getStr(m,"messageId") +"\"\n" +
                            "}";
                    String tr = HttpUtil.post(turl, pa);
                    Map<String, Object> rm = JsonUtil.toMap(tr);
                    String pp = BeanUtil.getProperty(rm, "$.data.body");
                    Map<String, Object> map1 = JsonUtil.toMap(pp);
                    String showName = BeanUtil.getProperty(map1, "$.data.showName");
                    String sign = BeanUtil.getProperty(map1, "$.type");

                    System.out.println(showName);
                    if(StrUtil.equals(sign,"sign")&&StrUtil.equals(showName,"全院会诊专家建议汇总")){
                        System.out.println("x");

                    }
                }
            });
        }

    }

}
